exports.register = (req,res)=> { 
    let user = global.dbHelper.getModel('user');  
    let md5 = crypto.createHash("md5");
    if(req.method == 'POST'){
		let username = req.body.username,
			password = req.body.password,    
			repassword = md5.update(password).digest("hex");  

		
		user.findOne({username: username},(error,doc)=>{
			if(error){
				console.log(error)
			}else if(doc){
				res.json({
					"code": 200,
					"msg": "账号已存在"
				});
			}else{
				user.create({
					username : username,
					password : password,
					repassword : repassword,
				},(error,doc) =>{
					if(error){
						logger.error("评论创建失败:"+error)
						res.json({
							"code": 500,
							"msg":"创建失败"
						})
					}else{
						res.json({
							"code": 200,
							"msg": "创建成功"
						})
					}   

				})
			}
		})   
    }
 }
